package com.siysoft.tc.admin.action;

import java.sql.Timestamp;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.siysoft.tc.admin.service.IAdminSchoolService;
import com.siysoft.tc.base.bean.property.ResourceType;
import com.siysoft.tc.base.bean.to.Resource;
import com.siysoft.util.IMap;
import com.siysoft.util.fileupload.FileUpload;

/**
 * <p>
 * Title: AdminSchoolController
 * </p>
 * <p>
 * Description:学校管理功能
 * </p>
 * <p>
 * Company: dmpb
 * </p>
 * 
 * @author victor
 * @date 2015年11月12日
 */
@Controller
@RequestMapping(value = "/admin/school")
public class AdminSchoolController {
	@Autowired
	IAdminSchoolService schoolService;

	// 学校信息管理
	@RequestMapping(value = "/toSchool")
	public String index(HttpServletRequest request) throws Exception {
		IMap iMap = new IMap(request);
		List<Map<String, Object>> seekSchools = schoolService.seekSchools(iMap);
		request.setAttribute("schoolList", seekSchools);
		return "/admin/school/schoolList";
	}

	// 查询学校信息
	@RequestMapping(value = "/toSchoolRevise")
	public String toSchoolRevise(HttpServletRequest request) throws Exception {
		IMap iMap = new IMap(request);
		Map<String, String> stuRevise = schoolService.toSchoolRevise(iMap);
		request.setAttribute("school", stuRevise);
		return "/admin/school/schoolRevise";
	}

	// 修改学校信息
	@RequestMapping(value = "/SchoolRevise")
	public String SchoolRevise(HttpServletRequest request) throws Exception {
		IMap iMap = new IMap(request);
		schoolService.reviseSchoolInfo(iMap);
		return "redirect:/admin/school/toSchool.htm";
	}

	//跳转添加学校页面
	@RequestMapping(value = "/toAddSchool")
	public String toAddSchool(HttpServletRequest request) throws Exception{
		System.out.println("asddddddddddddddddddafd");
		return "/admin/school/addSchool";
	}

	// 跳转添加学校页面
	@RequestMapping(value = "/addSchool")
	public String addSchool(HttpServletRequest request) throws Exception {
		IMap iMap = new IMap(request);
		Integer id = schoolService.addSchools(iMap);


		return "redirect:/admin/school/toSchool.htm";
	}
	
	//删除学校
	@RequestMapping(value = "/delSchool")
	public String delSchool(HttpServletRequest request) throws Exception{
		IMap iMap = new IMap(request);
		schoolService.delSchool(iMap);
		return "redirect:/admin/school/toSchool.htm";
	}

}
